package com.android.task5;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

import org.w3c.dom.Document;

import android.util.Log;

public class FlickrXMLRPCResponse {
	
	private final static String INFO_TAG = "Flickr XML-RPC Response Info";
	
	private DocumentBuilderFactory factory;
	private DocumentBuilder builder;
	private Document doc;
	
	private String realname;
	private String username;
	private String title;
	
	public FlickrXMLRPCResponse(){
		realname = "";
		username= "";
		title= "";
		try {

			factory = DocumentBuilderFactory.newInstance();
			builder = factory.newDocumentBuilder();
		
		} catch (ParserConfigurationException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	
	public String getRealname() {
		Log.i("http","realName: "+realname);
		return realname;
	}


	public String getUsername() {
		Log.i("http","username: "+username);
		return username;
	}


	public String getTitle() {
		Log.i("http","title: "+title);
		return title;
	}

	public void parseData(String output){
	Log.i("http","PARSING!!!");
	String[] searchUsernameTable = output.split("username");
	searchUsernameTable = searchUsernameTable[1].split(";");
	searchUsernameTable = searchUsernameTable[1].split("&");
	this.username = searchUsernameTable[0];
	Log.i("http", "username in parseData:" +this.username);
	
	String[] searchRealNameTable = output.split("realname");
	searchRealNameTable = searchRealNameTable[1].split(";");
	searchRealNameTable = searchRealNameTable[1].split("&");
	this.realname = searchRealNameTable[0];
	Log.i("http", "realname in parseData:" +this.realname);
	
	String[] searchTitle = output.split("title");
	searchTitle = searchTitle[1].split(";");
	searchTitle = searchTitle[1].split("&");
	this.title = searchTitle[0];
	Log.i("http", "title in parseData:" +this.title);
	
	}
	
//	public void parseDataWithDOM(String output){
//		doc = builder.parse(uri)
//	}
}
